{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>电器产品</th>\n",
       "      <th>业务员</th>\n",
       "      <th>时间</th>\n",
       "      <th>城市</th>\n",
       "      <th>数量</th>\n",
       "      <th>单价</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李可</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>541</td>\n",
       "      <td>125</td>\n",
       "      <td>67625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李可</td>\n",
       "      <td>秋季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>674</td>\n",
       "      <td>125</td>\n",
       "      <td>84250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李亮</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>720</td>\n",
       "      <td>125</td>\n",
       "      <td>90000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李亮</td>\n",
       "      <td>夏季</td>\n",
       "      <td>上海</td>\n",
       "      <td>641</td>\n",
       "      <td>125</td>\n",
       "      <td>80125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>MP3</td>\n",
       "      <td>张平</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>721</td>\n",
       "      <td>125</td>\n",
       "      <td>90125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>MP3</td>\n",
       "      <td>张平</td>\n",
       "      <td>夏季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>384</td>\n",
       "      <td>125</td>\n",
       "      <td>48000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>MP3</td>\n",
       "      <td>周顺利</td>\n",
       "      <td>夏季</td>\n",
       "      <td>上海</td>\n",
       "      <td>354</td>\n",
       "      <td>125</td>\n",
       "      <td>44250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>MP3</td>\n",
       "      <td>周顺利</td>\n",
       "      <td>秋季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>841</td>\n",
       "      <td>125</td>\n",
       "      <td>105125</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  电器产品  业务员  时间  城市   数量   单价     销售额\n",
       "0  MP3   李可  春季  上海  541  125   67625\n",
       "1  MP3   李可  秋季  青岛  674  125   84250\n",
       "2  MP3   李亮  春季  上海  720  125   90000\n",
       "3  MP3   李亮  夏季  上海  641  125   80125\n",
       "4  MP3   张平  春季  上海  721  125   90125\n",
       "5  MP3   张平  夏季  青岛  384  125   48000\n",
       "6  MP3  周顺利  夏季  上海  354  125   44250\n",
       "7  MP3  周顺利  秋季  青岛  841  125  105125"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "mydf = pd.read_excel('myexcel1.xls',sheet_name=1)\n",
    "mydf"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "电器产品      MP3\n",
       "业务员        李可\n",
       "时间         春季\n",
       "城市         上海\n",
       "数量        541\n",
       "单价        125\n",
       "销售额     67625\n",
       "Name: 0, dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf.loc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>电器产品</th>\n",
       "      <th>业务员</th>\n",
       "      <th>时间</th>\n",
       "      <th>城市</th>\n",
       "      <th>数量</th>\n",
       "      <th>单价</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李亮</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>720</td>\n",
       "      <td>125</td>\n",
       "      <td>90000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李亮</td>\n",
       "      <td>夏季</td>\n",
       "      <td>上海</td>\n",
       "      <td>641</td>\n",
       "      <td>125</td>\n",
       "      <td>80125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>MP3</td>\n",
       "      <td>张平</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>721</td>\n",
       "      <td>125</td>\n",
       "      <td>90125</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  电器产品 业务员  时间  城市   数量   单价    销售额\n",
       "2  MP3  李亮  春季  上海  720  125  90000\n",
       "3  MP3  李亮  夏季  上海  641  125  80125\n",
       "4  MP3  张平  春季  上海  721  125  90125"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf.loc[2:4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>电器产品</th>\n",
       "      <th>业务员</th>\n",
       "      <th>时间</th>\n",
       "      <th>城市</th>\n",
       "      <th>数量</th>\n",
       "      <th>单价</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李可</td>\n",
       "      <td>秋季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>674</td>\n",
       "      <td>125</td>\n",
       "      <td>84250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>MP3</td>\n",
       "      <td>李亮</td>\n",
       "      <td>夏季</td>\n",
       "      <td>上海</td>\n",
       "      <td>641</td>\n",
       "      <td>125</td>\n",
       "      <td>80125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>MP3</td>\n",
       "      <td>周顺利</td>\n",
       "      <td>夏季</td>\n",
       "      <td>上海</td>\n",
       "      <td>354</td>\n",
       "      <td>125</td>\n",
       "      <td>44250</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  电器产品  业务员  时间  城市   数量   单价    销售额\n",
       "1  MP3   李可  秋季  青岛  674  125  84250\n",
       "3  MP3   李亮  夏季  上海  641  125  80125\n",
       "6  MP3  周顺利  夏季  上海  354  125  44250"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf.loc[[1,3,6]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>业务员</th>\n",
       "      <th>城市</th>\n",
       "      <th>销售额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>李可</td>\n",
       "      <td>上海</td>\n",
       "      <td>67625</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>李可</td>\n",
       "      <td>青岛</td>\n",
       "      <td>84250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>李亮</td>\n",
       "      <td>上海</td>\n",
       "      <td>90000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>李亮</td>\n",
       "      <td>上海</td>\n",
       "      <td>80125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>张平</td>\n",
       "      <td>上海</td>\n",
       "      <td>90125</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>张平</td>\n",
       "      <td>青岛</td>\n",
       "      <td>48000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>周顺利</td>\n",
       "      <td>上海</td>\n",
       "      <td>44250</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>周顺利</td>\n",
       "      <td>青岛</td>\n",
       "      <td>105125</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   业务员  城市     销售额\n",
       "0   李可  上海   67625\n",
       "1   李可  青岛   84250\n",
       "2   李亮  上海   90000\n",
       "3   李亮  上海   80125\n",
       "4   张平  上海   90125\n",
       "5   张平  青岛   48000\n",
       "6  周顺利  上海   44250\n",
       "7  周顺利  青岛  105125"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#mydf.loc[0]\n",
    "#mydf.loc[:,'城市']\n",
    "#mydf.loc[:,'业务员':'数量']\n",
    "#mydf.loc[:,'时间':]\n",
    "#mydf.loc[:,:'时间']\n",
    "mydf.loc[:,['业务员','城市','销售额']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>编号</th>\n",
       "      <th>日期</th>\n",
       "      <th>姓名</th>\n",
       "      <th>性别</th>\n",
       "      <th>年龄</th>\n",
       "      <th>工资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>100001</td>\n",
       "      <td>2021-11-08</td>\n",
       "      <td>赵佳</td>\n",
       "      <td>女</td>\n",
       "      <td>25</td>\n",
       "      <td>5869.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>100012</td>\n",
       "      <td>2021-11-09</td>\n",
       "      <td>张可</td>\n",
       "      <td>男</td>\n",
       "      <td>28</td>\n",
       "      <td>7256.34</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>100003</td>\n",
       "      <td>2021-11-10</td>\n",
       "      <td>周远</td>\n",
       "      <td>女</td>\n",
       "      <td>21</td>\n",
       "      <td>6895.89</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>100004</td>\n",
       "      <td>2021-11-11</td>\n",
       "      <td>徐南</td>\n",
       "      <td>男</td>\n",
       "      <td>30</td>\n",
       "      <td>7289.72</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       编号         日期  姓名 性别  年龄       工资\n",
       "0  100001 2021-11-08  赵佳  女  25  5869.32\n",
       "1  100012 2021-11-09  张可  男  28  7256.34\n",
       "2  100003 2021-11-10  周远  女  21  6895.89\n",
       "3  100004 2021-11-11  徐南  男  30  7289.72"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "data = {  \"编号\":[100001,100012,100003,100004],\n",
    "          \"日期\":pd.date_range('20211108', periods=4),\n",
    "          \"姓名\":[\"赵佳\",\"张可\",\"周远\",\"徐南\"],\n",
    "          \"性别\":['女','男','女','男'],\n",
    "          \"年龄\":[25,28,21,30],\n",
    "          \"工资\":[5869.32,7256.34,6895.89,7289.72]\n",
    "       }\n",
    "mydf1 = pd.DataFrame(data) \n",
    "display(mydf1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>姓名</th>\n",
       "      <th>工资</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>赵佳</td>\n",
       "      <td>5869.32</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>周远</td>\n",
       "      <td>6895.89</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   姓名       工资\n",
       "0  赵佳  5869.32\n",
       "2  周远  6895.89"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#mydf1.loc[1,'姓名']\n",
    "#mydf1.loc[1:2,'姓名']\n",
    "#mydf1.loc[1,'姓名':'性别']\n",
    "#mydf1.loc[1,['编号','姓名','工资']]\n",
    "#mydf1.loc[0,'编号':'姓名']\n",
    "#mydf1.loc[0:2,'姓名']\n",
    "#mydf1.loc[0:2,['姓名','工资']]\n",
    "mydf1.loc[[0,2],['姓名','工资']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李可</td>\n",
       "      <td>冬季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>841</td>\n",
       "      <td>1320</td>\n",
       "      <td>1110120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李亮</td>\n",
       "      <td>秋季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>341</td>\n",
       "      <td>1320</td>\n",
       "      <td>450120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李亮</td>\n",
       "      <td>冬季</td>\n",
       "      <td>上海</td>\n",
       "      <td>641</td>\n",
       "      <td>1320</td>\n",
       "      <td>846120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>张平</td>\n",
       "      <td>冬季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>687</td>\n",
       "      <td>1320</td>\n",
       "      <td>906840</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>张平</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>354</td>\n",
       "      <td>1320</td>\n",
       "      <td>467280</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>周顺利</td>\n",
       "      <td>冬季</td>\n",
       "      <td>上海</td>\n",
       "      <td>541</td>\n",
       "      <td>1320</td>\n",
       "      <td>714120</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4  Unnamed: 5  \\\n",
       "0         NaN         冰箱         李可         冬季         青岛         841   \n",
       "1         NaN         冰箱         李亮         秋季         青岛         341   \n",
       "2         NaN         冰箱         李亮         冬季         上海         641   \n",
       "3         NaN         冰箱         张平         冬季         青岛         687   \n",
       "4         NaN         冰箱         张平         春季         上海         354   \n",
       "5         NaN         冰箱        周顺利         冬季         上海         541   \n",
       "\n",
       "   Unnamed: 6  Unnamed: 7  \n",
       "0        1320     1110120  \n",
       "1        1320      450120  \n",
       "2        1320      846120  \n",
       "3        1320      906840  \n",
       "4        1320      467280  \n",
       "5        1320      714120  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "mydf1 = pd.read_excel('myexcel1.xls',sheet_name=2,skiprows=3)\n",
    "display(mydf1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Unnamed: 0       NaN\n",
       "Unnamed: 1        冰箱\n",
       "Unnamed: 2        李亮\n",
       "Unnamed: 3        冬季\n",
       "Unnamed: 4        上海\n",
       "Unnamed: 5       641\n",
       "Unnamed: 6      1320\n",
       "Unnamed: 7    846120\n",
       "Name: 2, dtype: object"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf1.iloc[2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>张平</td>\n",
       "      <td>春季</td>\n",
       "      <td>上海</td>\n",
       "      <td>354</td>\n",
       "      <td>1320</td>\n",
       "      <td>467280</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>周顺利</td>\n",
       "      <td>冬季</td>\n",
       "      <td>上海</td>\n",
       "      <td>541</td>\n",
       "      <td>1320</td>\n",
       "      <td>714120</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4  Unnamed: 5  \\\n",
       "4         NaN         冰箱         张平         春季         上海         354   \n",
       "5         NaN         冰箱        周顺利         冬季         上海         541   \n",
       "\n",
       "   Unnamed: 6  Unnamed: 7  \n",
       "4        1320      467280  \n",
       "5        1320      714120  "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf1.iloc[4:]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 4</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "      <th>Unnamed: 7</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李可</td>\n",
       "      <td>冬季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>841</td>\n",
       "      <td>1320</td>\n",
       "      <td>1110120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李亮</td>\n",
       "      <td>秋季</td>\n",
       "      <td>青岛</td>\n",
       "      <td>341</td>\n",
       "      <td>1320</td>\n",
       "      <td>450120</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李亮</td>\n",
       "      <td>冬季</td>\n",
       "      <td>上海</td>\n",
       "      <td>641</td>\n",
       "      <td>1320</td>\n",
       "      <td>846120</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0 Unnamed: 1 Unnamed: 2 Unnamed: 3 Unnamed: 4  Unnamed: 5  \\\n",
       "0         NaN         冰箱         李可         冬季         青岛         841   \n",
       "1         NaN         冰箱         李亮         秋季         青岛         341   \n",
       "2         NaN         冰箱         李亮         冬季         上海         641   \n",
       "\n",
       "   Unnamed: 6  Unnamed: 7  \n",
       "0        1320     1110120  \n",
       "1        1320      450120  \n",
       "2        1320      846120  "
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf1.iloc[:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     李可\n",
       "1     李亮\n",
       "2     李亮\n",
       "3     张平\n",
       "4     张平\n",
       "5    周顺利\n",
       "Name: Unnamed: 2, dtype: object"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf1.iloc[:,2]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 6</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>冰箱</td>\n",
       "      <td>冬季</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>冰箱</td>\n",
       "      <td>秋季</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>冰箱</td>\n",
       "      <td>冬季</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>冰箱</td>\n",
       "      <td>冬季</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>冰箱</td>\n",
       "      <td>春季</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>冰箱</td>\n",
       "      <td>冬季</td>\n",
       "      <td>1320</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Unnamed: 1 Unnamed: 3  Unnamed: 6\n",
       "0         冰箱         冬季        1320\n",
       "1         冰箱         秋季        1320\n",
       "2         冰箱         冬季        1320\n",
       "3         冰箱         冬季        1320\n",
       "4         冰箱         春季        1320\n",
       "5         冰箱         冬季        1320"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf1.iloc[:,[1,3,6]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 0</th>\n",
       "      <th>Unnamed: 1</th>\n",
       "      <th>Unnamed: 2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李可</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李亮</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>李亮</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>张平</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>张平</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>NaN</td>\n",
       "      <td>冰箱</td>\n",
       "      <td>周顺利</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Unnamed: 0 Unnamed: 1 Unnamed: 2\n",
       "0         NaN         冰箱         李可\n",
       "1         NaN         冰箱         李亮\n",
       "2         NaN         冰箱         李亮\n",
       "3         NaN         冰箱         张平\n",
       "4         NaN         冰箱         张平\n",
       "5         NaN         冰箱        周顺利"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf1.iloc[:,:3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Unnamed: 3</th>\n",
       "      <th>Unnamed: 5</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>冬季</td>\n",
       "      <td>641</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>春季</td>\n",
       "      <td>354</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  Unnamed: 3  Unnamed: 5\n",
       "2         冬季         641\n",
       "4         春季         354"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#mydf1.iloc[1,2]\n",
    "#mydf1.iloc[3,[4,5]]\n",
    "mydf1.iloc[[2,4],[3,5]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>A</th>\n",
       "      <th>B</th>\n",
       "      <th>C</th>\n",
       "      <th>D</th>\n",
       "      <th>E</th>\n",
       "      <th>F</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.176065</td>\n",
       "      <td>-1.346276</td>\n",
       "      <td>-0.892158</td>\n",
       "      <td>-0.499429</td>\n",
       "      <td>-0.325607</td>\n",
       "      <td>-0.353104</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.387828</td>\n",
       "      <td>-1.456198</td>\n",
       "      <td>-0.827843</td>\n",
       "      <td>-1.119111</td>\n",
       "      <td>-0.426389</td>\n",
       "      <td>1.495828</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1.499658</td>\n",
       "      <td>0.616903</td>\n",
       "      <td>-0.581139</td>\n",
       "      <td>-0.114313</td>\n",
       "      <td>-0.256865</td>\n",
       "      <td>-0.456385</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.036439</td>\n",
       "      <td>0.441018</td>\n",
       "      <td>0.465942</td>\n",
       "      <td>-0.530366</td>\n",
       "      <td>-0.468964</td>\n",
       "      <td>1.018607</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.216281</td>\n",
       "      <td>-0.475464</td>\n",
       "      <td>-0.520467</td>\n",
       "      <td>-0.331176</td>\n",
       "      <td>2.647964</td>\n",
       "      <td>-1.286368</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>1.971354</td>\n",
       "      <td>0.314853</td>\n",
       "      <td>0.028867</td>\n",
       "      <td>-0.751329</td>\n",
       "      <td>-0.074215</td>\n",
       "      <td>-0.670037</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>-0.693392</td>\n",
       "      <td>0.558164</td>\n",
       "      <td>1.532648</td>\n",
       "      <td>-0.770055</td>\n",
       "      <td>0.299110</td>\n",
       "      <td>1.037544</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.100817</td>\n",
       "      <td>-0.097314</td>\n",
       "      <td>1.228057</td>\n",
       "      <td>0.332368</td>\n",
       "      <td>-1.211964</td>\n",
       "      <td>1.185179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.608637</td>\n",
       "      <td>0.930317</td>\n",
       "      <td>-0.474018</td>\n",
       "      <td>0.147846</td>\n",
       "      <td>0.237651</td>\n",
       "      <td>-2.125445</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>1.262023</td>\n",
       "      <td>-2.127068</td>\n",
       "      <td>-0.269538</td>\n",
       "      <td>-0.720196</td>\n",
       "      <td>-0.010381</td>\n",
       "      <td>-0.588315</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          A         B         C         D         E         F\n",
       "0 -0.176065 -1.346276 -0.892158 -0.499429 -0.325607 -0.353104\n",
       "1  0.387828 -1.456198 -0.827843 -1.119111 -0.426389  1.495828\n",
       "2  1.499658  0.616903 -0.581139 -0.114313 -0.256865 -0.456385\n",
       "3  0.036439  0.441018  0.465942 -0.530366 -0.468964  1.018607\n",
       "4  0.216281 -0.475464 -0.520467 -0.331176  2.647964 -1.286368\n",
       "5  1.971354  0.314853  0.028867 -0.751329 -0.074215 -0.670037\n",
       "6 -0.693392  0.558164  1.532648 -0.770055  0.299110  1.037544\n",
       "7  0.100817 -0.097314  1.228057  0.332368 -1.211964  1.185179\n",
       "8 -0.608637  0.930317 -0.474018  0.147846  0.237651 -2.125445\n",
       "9  1.262023 -2.127068 -0.269538 -0.720196 -0.010381 -0.588315"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "mydf = pd.DataFrame(np.random.randn(10,6),columns=['A','B','C','D','E','F'])\n",
    "display(mydf)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0    0.543957\n",
       "1    0.443399\n",
       "2    2.108819\n",
       "3   -0.589339\n",
       "4    0.226420\n",
       "5   -0.234485\n",
       "6    1.408668\n",
       "7    0.264870\n",
       "8   -0.177780\n",
       "9   -0.357866\n",
       "Name: B, dtype: float64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mydf.B"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Unnamed: 0\n",
      "Unnamed: 1\n",
      "Unnamed: 2\n",
      "Unnamed: 3\n",
      "Unnamed: 4\n",
      "Unnamed: 5\n",
      "Unnamed: 6\n",
      "Unnamed: 7\n"
     ]
    }
   ],
   "source": [
    "for mycol in mydf1:\n",
    "    print(mycol)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'DataFrame' object has no attribute 'iteritems'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[49], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key,value \u001b[38;5;129;01min\u001b[39;00m \u001b[43mmydf1\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43miteritems\u001b[49m():\n\u001b[0;32m      2\u001b[0m     \u001b[38;5;28mprint\u001b[39m(key,value)\n",
      "File \u001b[1;32mc:\\Users\\18027\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\generic.py:6296\u001b[0m, in \u001b[0;36mNDFrame.__getattr__\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m   6289\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[0;32m   6290\u001b[0m     name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_internal_names_set\n\u001b[0;32m   6291\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_metadata\n\u001b[0;32m   6292\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_accessors\n\u001b[0;32m   6293\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_info_axis\u001b[38;5;241m.\u001b[39m_can_hold_identifiers_and_holds_name(name)\n\u001b[0;32m   6294\u001b[0m ):\n\u001b[0;32m   6295\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m[name]\n\u001b[1;32m-> 6296\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mobject\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getattribute__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'iteritems'"
     ]
    }
   ],
   "source": [
    "for key,value in mydf1.iteritems():\n",
    "    print(key,value)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pandas(Index=0, 编号=100001, 日期=Timestamp('2021-12-18 00:00:00'), 姓名='赵佳', 性别='女', 年龄=25, 工资=5869.32)\n",
      "Pandas(Index=1, 编号=100012, 日期=Timestamp('2021-12-19 00:00:00'), 姓名='张可', 性别='男', 年龄=28, 工资=7256.34)\n",
      "Pandas(Index=2, 编号=100003, 日期=Timestamp('2021-12-20 00:00:00'), 姓名='周远', 性别='女', 年龄=21, 工资=6895.89)\n",
      "Pandas(Index=3, 编号=100004, 日期=Timestamp('2021-12-21 00:00:00'), 姓名='徐南', 性别='男', 年龄=30, 工资=7289.72)\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "data = {  \"编号\":[100001,100012,100003,100004],\n",
    "          \"日期\":pd.date_range('20211218', periods=4),\n",
    "          \"姓名\":[\"赵佳\",\"张可\",\"周远\",\"徐南\"],\n",
    "          \"性别\":['女','男','女','男'],\n",
    "          \"年龄\":[25,28,21,30],\n",
    "          \"工资\":[5869.32,7256.34,6895.89,7289.72]\n",
    "       }\n",
    "mydf1 = pd.DataFrame(data) \n",
    "# for mycol in mydf1:\n",
    "#     print(mycol)\n",
    "for row in mydf1.itertuples():\n",
    "    print(row)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'DataFrame' object has no attribute 'iteritems'",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAttributeError\u001b[0m                            Traceback (most recent call last)",
      "Cell \u001b[1;32mIn[65], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m key,value \u001b[38;5;129;01min\u001b[39;00m \u001b[43mmydf1\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43miteritems\u001b[49m():\n\u001b[0;32m      2\u001b[0m     \u001b[38;5;28mprint\u001b[39m(key,value)\n",
      "File \u001b[1;32mc:\\Users\\18027\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\pandas\\core\\generic.py:6296\u001b[0m, in \u001b[0;36mNDFrame.__getattr__\u001b[1;34m(self, name)\u001b[0m\n\u001b[0;32m   6289\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m (\n\u001b[0;32m   6290\u001b[0m     name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_internal_names_set\n\u001b[0;32m   6291\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_metadata\n\u001b[0;32m   6292\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m name \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;129;01min\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_accessors\n\u001b[0;32m   6293\u001b[0m     \u001b[38;5;129;01mand\u001b[39;00m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_info_axis\u001b[38;5;241m.\u001b[39m_can_hold_identifiers_and_holds_name(name)\n\u001b[0;32m   6294\u001b[0m ):\n\u001b[0;32m   6295\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28mself\u001b[39m[name]\n\u001b[1;32m-> 6296\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mobject\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[38;5;21;43m__getattribute__\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mself\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mname\u001b[49m\u001b[43m)\u001b[49m\n",
      "\u001b[1;31mAttributeError\u001b[0m: 'DataFrame' object has no attribute 'iteritems'"
     ]
    }
   ],
   "source": [
    "for key,value in mydf1.iteritems():\n",
    "    print(key,value)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
